/**
 * DropdownItem
 * @Author ace.ch
 * @Date 2018/1/24 18:04
 */
class DropdownItem extends BaseSprite {

    static SELECTED: string = 'DROPDOWNITEM_SELECTED';

    private value: eui.Image;

    private _data: any;

    sign: string;

    constructor() {
        super();

        this.skinName = 'DropdownItemSkin';
    }

    childrenCreated() {
        super.childrenCreated();

        this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickHandler, this);
    }

    private clickHandler(e: egret.TouchEvent) {
        gameManager.i.dispatchEvent(DropdownItem.SELECTED, {sign: this.sign, value: this.data});
    }

    get data(): string {
        return this._data;
    }

    set data(v: string) {
        this._data = v;
        this.value.source = v;
    }
}